package com.aurora.source.center.presenter;

import android.content.Context;

import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.center.view.IAddFlowView;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * @author: ww
 * @description:
 * @date: 2018/9/29
 */
public class AddFlowPresenter extends BasePresenter<IAddFlowView>{
    public AddFlowPresenter(IAddFlowView baseView) {
        super(baseView);
    }

    public void addFlowRecoredBytes(Map<String, String> params2, List<byte[]> files) {
        requestMethod.addFlowRecoredBytes(params2, files, new SubscriberObserver<BaseBean>((Context)baseView,"正在提交数据...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if(baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)){
                    baseView.onAddFlowRecoredSuccess(baseBean.getMsg());
                }else {
                    baseView.onAddFlowRecoredFail(baseBean.getMsg());
                }

            }

            @Override
            public void onError(String msg) {
                baseView.onAddFlowRecoredFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }

    public void addFlowRecored(Map<String, String> params2, List<File> files) {
        requestMethod.addFlowRecored(params2, files, new SubscriberObserver<BaseBean>((Context)baseView,"正在提交数据...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if(baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)){
                    baseView.onAddFlowRecoredSuccess(baseBean.getMsg());
                }else {
                    baseView.onAddFlowRecoredFail(baseBean.getMsg());
                }

            }

            @Override
            public void onError(String msg) {
                baseView.onAddFlowRecoredFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
